package com.wyl.xyg.sample.model;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
@Entity
@Table(name = "appointment")
@NamedQueries( {
	@NamedQuery(name = Appointment.ALL, query = "select a from Appointment a order by id desc"),
	@NamedQuery(name = Appointment.BY_DATETIME, query = "select a from Appointment a where a.theDate between :startDatetime and :endDatetime")
})

public class Appointment {
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "id", unique = true, nullable = false, insertable = true, updatable = true)
	public Long id;

	@Column(name = "name", unique = false, nullable = true, insertable = true, updatable = true)
	@NotNull(message = "姓名不能为空")
	@Size(min=2, max=30)
	public String name;
	
	@Column(name = "code", unique = false, nullable = true, insertable = true, updatable = true)
	public String code;
	
	@Column(name = "business_type", unique = false, nullable = true, insertable = true, updatable = true)
	@NotNull(message = "业务类型不能为空")
	public String businessType;
	
	@Column(name = "id_type", unique = false, nullable = true, insertable = true, updatable = true)
	public String idType;
	
	@Column(name = "id_type_no", unique = false, nullable = true, insertable = true, updatable = true)
	public String idTypeNo;
	
	@Column(name = "telphone", unique = false, nullable = true, insertable = true, updatable = true)
	@NotNull(message = "联系电话不能为空")
	@Size(min=2, max=11)
	@Pattern(regexp="^1[358]\\d{9}$")  
	public String telphone;
	
	@Column(name = "the_date", unique = false, nullable = true, insertable = true, updatable = true)
	@NotNull(message = "预约时间不能为空")
	public Date theDate;
	
	@Column(name = "status", unique = false, nullable = true, insertable = true, updatable = true)
	public String status;
	
	private String comment;
	
	public final static String ALL="Appointment.all";
	public final static String BY_DATETIME="Appointment.byDatetime";
	
	public Appointment() {
		super();
	}


	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	
	public String getBusinessType() {
		return businessType;
	}

	public void setBusinessType(String businessType) {
		this.businessType = businessType;
	}

	public String getIdType() {
		return idType;
	}

	public void setIdType(String idType) {
		this.idType = idType;
	}

	public String getIdTypeNo() {
		return idTypeNo;
	}

	public void setIdTypeNo(String idTypeNo) {
		this.idTypeNo = idTypeNo;
	}

	public String getName() {
		return name;
	}


	public void setName(String name) {
		this.name = name;
	}


	public String getCode() {
		return code;
	}


	public void setCode(String code) {
		this.code = code;
	}




	public String getTelphone() {
		return telphone;
	}


	public void setTelphone(String telphone) {
		this.telphone = telphone;
	}



	public Date getTheDate() {
		return theDate;
	}

	public void setTheDate(Date theDate) {
		this.theDate = theDate;
	}



	public String getStatus() {
		return status;
	}



	public void setStatus(String status) {
		this.status = status;
	}


	public String getComment() {
		return comment;
	}


	public void setComment(String comment) {
		this.comment = comment;
	}


	
}
